package cn.net.yto.school.service.impl;

import cn.net.yto.base.dao.pagination.PaginationRequest;
import cn.net.yto.base.dao.pagination.PaginationResponse;
import cn.net.yto.school.dao.entities.TbFile;
import cn.net.yto.school.dao.repositories.TbFileRepository;
import cn.net.yto.school.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class FileServiceImpl implements FileService {

    @Autowired
    private TbFileRepository fileRepository;

    @Override
    public PaginationResponse<TbFile> findResultsByPagination(PaginationRequest paginationRequest) {
        return this.fileRepository.findResultsByPagination(paginationRequest);
    }

    @Override
    @Transactional
    public void deleteFileById(Integer id) {
        this.fileRepository.delete(id);
    }

    @Override
    public TbFile findOneById(Integer id) {
        return this.fileRepository.findOne(id);
    }

    @Override
    @Transactional
    public void saveFile(TbFile file) {
        this.fileRepository.save(file);
    }
}
